<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>

<script type="text/javascript">
	var collarid;
	$(function() {

		collarid = $('#collarid')
				.datagrid(
						{
							//title : '列表',
							url : '${ctx}/autoinn/collar/list',
							striped : true,
							rownumbers : true,
							pagination : true,
							singleSelect : true,
							idField : 'id',						
							sortName : 'id',
							sortOrder : 'desc',
							pageSize : 50,
							pageList : [ 10, 20, 30, 40, 50, 100, 200, 300,
									400, 500 ],
							frozenColumns : [ [ 
							{
								width : '120',
								title : '用户名称',
								field : 'nickname',
							
							} ] ],
							columns : [ [
									{
										width : '130',
										title : '优惠券名称',
										field : 'coupon_name',
										
									},
									{
										width : '90',
										title : '发放类型',
										field : 'coupon_zhi',
										formatter : function(value, row) {
											switch(value){
											case 0:
												return sy.formatString("<span align='center'>绑定送券</span>");
											case 1:
												return sy.formatString("<span align='center'>充值送券</span>");
											case 2:
												return sy.formatString("<span align='center'>消费送券</span>");
											case 3:
												return sy.formatString("<span align='center'>人工送券</span>");
											default:
												return '';
											}
											
										}
										
									},
									{
										width : '130',
										title : '领取时间',
										field : 'collarTime',

									},
									{
										width : '60',
										title : '状态',
										field : 'state',
										formatter : function(value, row) {
											if (value==0) {
												return sy.formatString("<span align='center'>未启用</span>");
											} else {
												return sy.formatString("<span align='center'>启用</span>");
											}
										}
									},																												
									{
										width : '50',
										title : '有效期',
										field : 'soupon_qi'
									},
									{
										width : '80',
										title : '操作',
										field : 'action',
										formatter : function(value, row) {
											var str = "";
											
											<shiro:hasPermission name="/autoinn/collar/delete">
											str += sy
													.formatString(
															'<span onclick="couponremoveFun(\'{0}\');" style="margin-left:3px;cursor:pointer;">【{1}】</span>',
															row.id, "删除");
                                            </shiro:hasPermission>
                                           
											return str;
										}
									} ] ],
							toolbar : '#coupontoolbar',
							onBeforeLoad : function(param) {
								parent.$.messager.progress({
									text : '数据加载中....'
								});
							},
							onLoadSuccess : function(data) {
								
								parent.$.messager.progress('close');
							}

						});
	});

	//删除
	var couponremoveFun = function(id) {
		parent.$.messager.confirm('询问', '您确定要删除此记录？', function(r) {
			if (r) {
				$.post('${ctx}/autoinn/collar/delete/' + id, function() {
					collarid.datagrid('reload');					
				}, 'json');
			}
		});
	};
	
	
</script>
<!-- 界面布局  -->
<div class="easyui-layout" style="width: 100%; height: 100%;"
	data-options="fit:true,border:false">

	<div id="coupontoolbar" style="display: none;">

		<table>
			<tr>
				<td>
					<form id="couponsearchForm">
						<table>
							<tr style="font-size: 13px;">
								<td>用户名称</td>
								<td><input name="nickname" style="width: 80px;" /></td>
								<td>发放类型</td>
								<td><select name="couponZhi" style="width:150px">
								<option value="">--请选择--</option>
								<option value="0">绑定送券</option>
								<option value="1">充值送券</option>
								<option value="2">消费送券</option>
								<option value="3">人工送券</option>
								</select></td>
								<td>状态</td>
								<td><select name="state">
								<option value="">--请选择--</option>
								  <option value="1">启用</option>
								  <option value="0">未启用</option>
								</select></td>
							  <td>
							  领取时间：
							  </td>	
							 <td>
							   <input name="starinnertime" class="Wdate"
									onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
									readonly="readonly" style="width: 120px;" />-<input
									name="endinnertime" class="Wdate"
									onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})"
									readonly="readonly" style="width: 120px;" /></input>
							  </td>

								<td><a href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-search',plain:true"
									onclick="collarid.datagrid('load',sy.serializeObject($('#couponsearchForm')));">过滤</a><a
									href="javascript:void(0);" class="easyui-linkbutton"
									data-options="iconCls:'icon-reload',plain:true"
									onclick="$('#couponsearchForm input').val('');collarid.datagrid('load',{});">重置过滤</a></td>
							</tr>
						</table>
					</form>
				</td>
			</tr>
			<tr>
				<td>
					
				</td>
			</tr>
		</table>
	</div>
	<div data-options="region:'center',title:'优惠券管理'" style="padding: 2px;">
		<div class="easyui-layout" data-options="fit : true,border : false">
			<div data-options="region:'center',border:false">
				<table id="collarid" data-options="fit:true,border:false"></table>
			</div>
		</div>
	</div>
	<!-- 	<div data-options="region:'east', split:true" style="width: 320px;">
		<div class="easyui-panel"
			data-options="fit:true,border:false,title:'权限设置'"
			style="padding: 10px;" id="user-panel"></div>
	</div> -->
</div>